package com.unieagle.exam.model;

import org.json.JSONObject;

import android.os.Parcel;
import android.os.Parcelable;


public class Subject implements Parcelable{

	private long id;
	
	private long parentId;
	
	private String title;
	
	private String update_status;
	
	public Subject() {
		id = -1; 
	}
	
	public static Subject parse(JSONObject obj) {
		Subject subject = new Subject();
		subject.setId(obj.optLong("id"));
		subject.setParentId(obj.optLong("parent_subject_id"));
		subject.setTitle(obj.optString("title"));
		subject.setUpdateStatus(obj.optString("update_status"));
		return subject;
	}

	public String getUpdateStatus() {
		return update_status;
	}

	public void setUpdateStatus(String update_status) {
		this.update_status = update_status;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public long getParentId() {
		return parentId;
	}

	public void setParentId(long parentId) {
		this.parentId = parentId;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}
	
	public static final Parcelable.Creator<Subject> CREATOR = new Creator<Subject>() {
		
		@Override  
		public Subject createFromParcel(Parcel source) {  
			Subject subject = new Subject();
			subject.setId(source.readLong());
			subject.setParentId(source.readLong());
			subject.setTitle(source.readString());
			return subject;  
		}

		@Override
		public Subject[] newArray(int arg0) {
			return new Subject[arg0];
		}
	};

	@Override
	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void writeToParcel(Parcel arg0, int arg1) {
		arg0.writeLong(id);
		arg0.writeLong(parentId);
		arg0.writeString(title);
	}
	
	
}
